package com.hyjx.framework.component.propertyconfig;

import com.hyjx.framework.common.CommonUtil;
import com.hyjx.framework.orm.dao.IBaseDao;
import com.hyjx.framework.orm.dao.Pager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class PropertyConfigServiceImpl implements PropertyConfigService {

    @Resource
    IBaseDao dao;

    @Override
    public String queryList(PropertyConfigModel model) {
        //dao.queryObject("propertyConfig.queryList", model);
        Pager pager = dao.getPager(model.getModuleName() + ".queryList", model.getModuleName() + ".queryCount", model);
        return CommonUtil.getPageJsonStr(pager);
    }

    @Override
    public boolean add(PropertyConfigModel model) {
        boolean flag = this.dao.addObject(model.getModuleName() + ".insert", model);
        return flag;
    }

    @Override
    public Object getInfoById(String s) {
        return this.dao.queryObject(new PropertyConfigModel().getModuleName() + ".getInfoById", s);
    }

    @Override
    public int delete(PropertyConfigModel model) {
        return this.dao.deleteObject(model.getModuleName() + ".delete", model.getProperty_id());
    }

    @Override
    public int edit(PropertyConfigModel model) {
        return this.dao.updateObject(model.getModuleName() + ".update", model);
    }

    @Override
    public List<PropertyConfigModel> getAllConfigs() {
        return (List<PropertyConfigModel>) dao.queryObjectList(new PropertyConfigModel().getModuleName() + ".getAllConfigs", null);
    }

    @Override
    public Object getInfoByKey(String key) {
        // TODO Auto-generated method stub
        return this.dao.queryObject(new PropertyConfigModel().getModuleName() + ".getInfoByKey", key);
    }
}
